package com.mxpio.erp.common.sales.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.inventory.entity.Warehouse;
import com.mxpio.erp.common.technology.entity.ItemGroup;
import com.mxpioframework.jpa.annotation.DictAble;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.jpa.policy.impl.CreatedDatePolicy;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.Dept;
import com.mxpioframework.security.entity.User;
import com.mxpioframework.security.service.policy.CreateDeptPolicy;
import com.mxpioframework.security.service.policy.CreatorPolicy;
import com.mxpioframework.security.service.policy.ModifierPolicy;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Data
@Schema(description="销售订单明细行执行明细（单条流水数据维度，数量对应销售出、销售退）")
public class SOLineExecDetailVO implements DictAble, Serializable {

	private static final long serialVersionUID = 1L;
	
	@Id
	@Schema(description = "流水号")
	private String id;

	@Schema(description = "出入类型")
	private String accessType;
	
	@Schema(description = "物料代码")
	private String itemCode;
	
	@Schema(description = "流水执行数量(实际发货数/计划退货数)")
	private BigDecimal quantity;
	
	@Schema(description = "批次号")
	private String lotNo;

	@Schema(description = "子批次索引号")//无子批默认为0
	private String subLotIndex;

	@Schema(description = "来源单号")
	private String originBizNo;
	
	@Schema(description = "来源单据类型")
	private String originBizType;
	
	@Schema(description = "来源单行号")
	private String originBizLineNo;
	
	@Schema(description = "仓单单号")
	private String woBizNo;
	
	@Schema(description = "仓单行号")
	private String woBizLineNo;
	
	@Schema(description = "仓单类型")
	@Dict(dicCode = "ERP_INV_WO_TYPE")
	private String woBizType;
	
	@Schema(description = "仓库编号")
	@Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
	private String whCode;
	
	@Schema(description = "备注")
	private String memo;


	@Schema(description = "物料名称")
	private String itemName;

	@Schema(description = "物料组")
	@Dict(dicCode="groupCode", dicEntity = ItemGroup.class, dicText = "groupName")
	private String itemGroupCode;

	@Schema(description = "物料规格")
	private String itemSpec;

	@Schema(description = "单位编号")
	@Dict(dicCode="ERP_TECH_UNIT_CODE")
	private String unitCode;

	@Schema(description = "来源通知单单号")
	private String originNoticeNo;

	@Schema(description = "来源通知单行号")
	private String originNoticeLineNo;

	@Schema(description = "创建人")
	@Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
	private String createBy;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Schema(description = "创建时间")
	private Date createTime;
	@Transient
	private Map<String, String> textMap;

	public String putText(String key, String value) {
		if (textMap == null) {
			textMap = new HashMap<>();
		}
		return textMap.put(key, value);
	}
}
